﻿CREATE PROCEDURE USP_GET_ARGUMENT
	@ArgumentId int, 
	@Depth int
AS 

	SET NOCOUNT ON;

	declare @Nodes table (
		id int
	)

	declare @Edges table (
		id int,
		parent int,
		child int
	)

	declare @OpenEdges table (
		id int,
		parent int,
		child int
	)

	declare @OpenNodes table (
		id int
	)

	-- Start it off
	insert into @OpenNodes
	select @ArgumentId

	declare @depthCount int;

	while (@depthCount <= @Depth or @Depth is null or @Depth < 0) and exists(select 1 from @OpenNodes)
	begin
		insert into @OpenEdges
		select id, parent, child
		from ArgumentLink


	end